home *** CD-ROM | disk | FTP | other *** search
/ Aminet 41 / Aminet 41 (2001)(Schatztruhe)[!][Feb 2001].iso / Aminet / dev / c / libiconv_src.lha / tests / check-stateless < prev    next >
Encoding:
Text File  |  2000-11-07  |  1.0 KB  |  24 lines

  1. #!/bin/sh
  2. # Complete check of a stateless encoding.
  3. # Usage: check-stateless SRCDIR CHARSET
  4. srcdir="$1"
  5. charset="$2"
  6. set -e
  7. ./table-from "$charset" > tmp-"$charset".TXT
  8. ./table-to "$charset" | sort > tmp-"$charset".INVERSE.TXT
  9. cmp "${srcdir}"/"$charset".TXT tmp-"$charset".TXT 2> /dev/null
  10. if test -f "${srcdir}"/"$charset".IRREVERSIBLE.TXT; then
  11.   cat "${srcdir}"/"$charset".TXT "${srcdir}"/"$charset".IRREVERSIBLE.TXT | sort | uniq -u > tmp-orig-"$charset".INVERSE.TXT
  12.   cmp tmp-orig-"$charset".INVERSE.TXT tmp-"$charset".INVERSE.TXT 2> /dev/null
  13. else
  14.   cmp "${srcdir}"/"$charset".TXT tmp-"$charset".INVERSE.TXT 2> /dev/null
  15. fi
  16. rm -f tmp-"$charset".TXT tmp-"$charset".INVERSE.TXT tmp-orig-"$charset".INVERSE.TXT
  17. exit 0
  18. # For a new encoding:
  19. # You can create the "$charset".TXT like this:
  20. #   ./table-from "$charset" > "$charset".TXT
  21. # You can create the "$charset".IRREVERSIBLE.TXT like this:
  22. #   ./table-to "$charset" | sort > "$charset".INVERSE.TXT
  23. #   diff "$charset".TXT "$charset".INVERSE.TXT | grep '^[<>]' | sed -e 's,^. ,,' > "$charset".IRREVERSIBLE.TXT
  24.